package com.mcgrady.exception;

import org.junit.Test;

/**
 * @author McGrady
 */
public class ExceptionThrowTest {
    private void throwsTest(int num) throws ArithmeticException,NullPointerException{
        System.out.println(100/num);
    }
    @Test
    public void throwsTest(){
        try {
            throwsTest(0);
        } catch (Exception e) {
            System.out.println("记录日志...");
            System.out.println("发短信给开发人员");
            e.printStackTrace();
        }
    }

    private void throwTest(int num){
        if (num == 0){
            throw new ArithmeticException("不能为0啊！！！");
        }
    }
    @Test
    public void throwTest(){
        try {
            throwTest(0);
        } catch (Exception e) {
            System.out.println("记录日志...");
            System.out.println("发短信给开发人员");
            e.printStackTrace();
        }
    }
}
